package com.restaurant.application.indexes.couponmanagelist;

import com.nebutown.description.DataTypes;
import com.nebutown.description.IndexGen;
import com.nebutown.description.UnitDescription;
import com.nebutown.description.data.Contributor;
import com.nebutown.description.data.IndexUnit;
import com.nebutown.description.data.SQLColumn;
import com.nebutown.generation.BeanSpec;
import com.restaurant.application.indexes.couponmanagelist.mysql.CouponManageListCriteria;

/**
 * @author Administrator
 */
public class AssistCouponManageListDesc extends UnitDescription {

    public static void main(String[] args) {
        getUnitDescription().run("./");
        IndexGen.run(getDescription(), "src/main/java");
    }


    private static UnitDescription getUnitDescription() {
        UnitDescription desc = UnitDescription.basicUnit(AssistCouponManageList.class, null);

        desc.nextBean("DeleteData").add("idList", BeanSpec.listOf("CouponManageIdData"));
        desc.nextBean("CouponManageIdData").add("id", String.class);

        desc.nextBean("CouponManageListData")
                .add("id", String.class)
                .add("name", String.class);

        desc.addUiFunction("delete", "DeleteData");
        desc.addUiFunction("search", CouponManageListCriteria.class.getName());
        desc.addUiFunction("modify", null);
        desc.addUiFunction("crateCD", null);
        desc.addUiFunction("crateCS", null);
        desc.addUiFunction("crateCL", null);
        return desc;
    }

    public static IndexUnit getDescription() {
        return new IndexUnit()
                .withName("CouponManageList")
                .withPackageName(AssistCouponManageListDesc.class.getPackage().getName() + ".mysql")
                .withSrcLocation("./")
                .addContributors(new Contributor()
                        .withName("couponManageUid")
                        .withNullable(false)
                        .withUnique(true)
                        .withUnitType(CouponManagePre.class.getName())
                        .addContribution(getSQLColumn("id", DataTypes.STRING, "优惠券管理id", 255))
                        .addContribution(getSQLColumn("number", DataTypes.STRING, "优惠券管理id", 255))
                        .addContribution(getSQLColumn("createTime", DataTypes.LONG, "创建时间", 20))
                        .addContribution(getSQLColumn("modifyTime", DataTypes.LONG, "修改时间", 20))
                        .addContribution(getSQLColumn("receiveTime", DataTypes.LONG, "服务开始时间", 20))
                        .addContribution(getSQLColumn("endTime", DataTypes.LONG, "服务期限时间", 20))
                        .addContribution(getSQLColumn("type", DataTypes.STRING, "优惠券类型", 255))
                        .addContribution(getSQLColumn("modality", DataTypes.STRING, "优惠券形式", 255))
                        .addContribution(getSQLColumn("fullMoney", DataTypes.DOUBLE, "满多少金额", 255))
                        .addContribution(getSQLColumn("minusMoney", DataTypes.DOUBLE, "减多少金额", 255))
                        .addContribution(getSQLColumn("shopUid", DataTypes.STRING, "店铺Uid", 255))
                        .addContribution(getSQLColumn("shopName", DataTypes.STRING, "店铺名称", 255))
                        .addContribution(getSQLColumn("remarks", DataTypes.STRING, "备注（注意事项）", 255))
                        .addContribution(getSQLColumn("totalAmount", DataTypes.STRING, "总数", 255))
                        .addContribution(getSQLColumn("amount", DataTypes.STRING, "已有数", 255))
                        .addContribution(getSQLColumn("state", DataTypes.STRING, "状态", 255))
                        .addContribution(getSQLColumn("limitId", DataTypes.STRING, "状态", 255))
                        .addContribution(getSQLColumn("limitAccount", DataTypes.STRING, "状态", 255))
                );
    }

    private static SQLColumn getSQLColumn(String name, DataTypes type, String label, Integer width) {
        return new SQLColumn().withName(name).withType(type).withLabel(label).withWidth(width);
    }
}
